<?php
	include '..'.DIRECTORY_SEPARATOR.'db-connection'.DIRECTORY_SEPARATOR.'conn.php';
	class clsEssentials
	{
		function LoginProcess($username,$password)
		{	
			$sql = "SELECT COUNT(*) as cntAdmin FROM tbl_users WHERE user_name='".$username."' AND password='".$password."' AND is_active='Y' AND is_admin='Y'";
			$run = mysql_query($sql);
			while ($data = mysql_fetch_array($run))
			{
				$cntAdmin = $data['cntAdmin'];
			}
			return $cntAdmin;
		}
		
		function getAllCategories()
		{
			$sql = "SELECT id,category_name FROM tbl_category_mst WHERE is_active='Y'";
			$run = mysql_query($sql);
			$counter=0;
			$arrCategory = array();
			while ($data = mysql_fetch_array($run))
			{
				$arrCategory[$counter]["id"] = stripslashes($data["id"]);
				$arrCategory[$counter]["category_name"] = stripslashes($data["category_name"]);
				$counter++;
			}
			return $arrCategory;
		}
		
		function getAllSubCategories()
		{
			$sql = "SELECT b.id, b.subcat_name, a.category_name FROM tbl_category_mst a, tbl_subcategory_mst b, tbl_category_subcategory_map c
			WHERE 
			a.id=c.category_id AND 
			b.id = c.subcategory_id AND 
			a.is_active='Y'";
			//print $sql;
			$run = mysql_query($sql);
			$counter=0;
			$arrCategory = array();
			while ($data = mysql_fetch_array($run))
			{
				$arrCategory[$counter]["id"] = stripslashes($data["id"]);
				$arrCategory[$counter]["category_name"] = stripslashes($data["category_name"]);
				$arrCategory[$counter]["subcategory_name"] = stripslashes($data["subcat_name"]);
				$counter++;
			}
			return $arrCategory;
		}
		
		
		function getAllUsers()
		{
			$sql = "SELECT a.int_user_id, a.txt_user_name, b.txt_role_name, a.yn_is_active FROM tbl_user_master a, tbl_role_master b WHERE a.int_role_assigned=b.int_role_id";
			$run = mysql_query($sql);
			$counter=0;
			$arrCategory = array();
			while ($data = mysql_fetch_array($run))
			{
				$arrCategory[$counter]["id"] = stripslashes($data["int_user_id"]);
				$arrCategory[$counter]["txt_user_name"] = stripslashes($data["txt_user_name"]);
				$arrCategory[$counter]["txt_role_name"] = stripslashes($data["txt_role_name"]);
				$arrCategory[$counter]["yn_is_active"] = stripslashes($data["yn_is_active"]);
				$counter++;
			}
			return $arrCategory;
		}
		
		function getAllVideoDetails()
		{
			$sql = "SELECT 
					tvm.int_video_id, tvm.txt_video_title, tvm.txt_video_desc, tvm.txt_video_path, tvm.txt_thumb_video_path, tvm.txt_keywords,
					tvm.yn_is_public, tcm.category_name, tsm.subcat_name, tum.int_user_id, tum.txt_first_name, tum.txt_last_name
					FROM 
					tbl_video_master tvm, tbl_user_master tum, tbl_category_mst tcm, tbl_subcategory_mst tsm
					WHERE
					tvm.int_uploader_user_id = tum.int_user_id
					AND tvm.int_cat_id = tcm.id
					AND tvm.int_sub_cat_id = tsm.id";
			$run = mysql_query($sql);
			$counter=0;
			$arrVideoDetails = array();
			while ($data = mysql_fetch_array($run))
			{
				$arrVideoDetails[$counter]["int_video_id"] = stripslashes($data["int_video_id"]);
				$arrVideoDetails[$counter]["txt_video_title"] = stripslashes($data["txt_video_title"]);
				$arrVideoDetails[$counter]["txt_video_desc"] = stripslashes($data["txt_video_desc"]);
				$arrVideoDetails[$counter]["txt_video_path"] = stripslashes($data["txt_video_path"]);
				$arrVideoDetails[$counter]["txt_thumb_video_path"] = stripslashes($data["txt_thumb_video_path"]);
				$arrVideoDetails[$counter]["txt_keywords"] = stripslashes($data["txt_keywords"]);
				$arrVideoDetails[$counter]["yn_is_public"] = stripslashes($data["yn_is_public"]);
				$arrVideoDetails[$counter]["category_name"] = stripslashes($data["category_name"]);
				$arrVideoDetails[$counter]["subcat_name"] = stripslashes($data["subcat_name"]);
				$arrVideoDetails[$counter]["int_user_id"] = stripslashes($data["int_user_id"]);
				$arrVideoDetails[$counter]["txt_first_name"] = stripslashes($data["txt_first_name"]);
				$arrVideoDetails[$counter]["txt_last_name"] = stripslashes($data["txt_last_name"]);
				$counter++;
			}
			return $arrVideoDetails;
		}
		
		
		
	}